// JavaScript Document
// Update price field Tax
function setTax(source, destination, tax) 
{
	var value = 0;
	value = Math.round(eval(source.value.replace(/\,/gi, ".").replace(/[^\d\.]/gi, "") * tax) * 100000) / 100000;
	jQuery("input."+destination+"").val(value);
}

function setVal(id, value, name)
{
	value = validVar(id, value, name);
	
	if(document.getElementById(id))
	{ document.getElementById(id).value=value; }
	
	if(name != '')
	{ jQuery("input[name="+name+"]").val(value); }
}

function validVar(id, value, name)
{
	var oldname;
	oldname = name;
	name = stripStringNumbers(name);
	switch (name)
	{
		case 'var_title_': case 'vt': case 'identity_': case 'idty': case 'ext_identity_': case 'exidty': 
		  value = removeInvalidCharsStr(value);
		  break;
		case 'buy_min_': case 'bm': case 'stock_count_': case 'sc': case 'stock_add_quan_': case 'saq':  case 'net_weight_': case 'nw': case 'gros_weight_': case 'gw':
			jQuery("input[name="+oldname+"]").numeric();
		  break;
		case 'length_': case 'ln': case 'width_': case 'wt': case 'height_': case 'ht': 
			jQuery("input[name="+oldname+"]").numeric();
		  break;
		case 'sp': case 'np': case 'op':
			jQuery("input[name="+oldname+"]").numeric(".").floatnumber(".",2);
		  break;
	}
	return value;
}